/*
 * cx_datetime_symbian.c
 *
 *  Created on: 2010-3-9
 *      Author: raycchen
 */

#include "cx_predef.h"
#include "cx_datetime.h"
#include "QOsBase.h"

#ifdef CX_PLATFORM_SYMBIAN

QVOID cx_getLocalTime(QTime* p)
{
    if (p) {
//        SYSTEMTIME t = {0};
//        GetLocalTime(&t);
//        p->wYear = (QUSHORT) t.wYear;
//        p->nMonth = (QBYTE) t.wMonth;
//        p->nDay = (QBYTE) t.wDay;
//        p->nHour = (QBYTE) t.wHour;
//        p->nMin = (QBYTE) t.wMinute;
//        p->nSec = (QBYTE) t.wSecond;
    	    TTime now1;
    		now1.HomeTime();
    		//TTime iLastPlayTime;
    		//iLastPlayTime.HomeTime();
    		//TTimeIntervalMicroSeconds deltaspend = now1.MicroSecondsFrom(iLastPlayTime);	
    		TUint nMillSeconds ;

    		TDateTime Date = now1.DateTime();//.Day()
    		p->wYear = Date.Year();
    		//p->wWeekDay =1;
    		p->nMonth =Date.Month();
    		p->nDay = Date.Day();
    		p->nHour = Date.Hour();
    		p->nMin = Date.Minute();
    		p->nSec =Date.Second();    	
    		p->nMicroSec = Date.MicroSecond();
    }   
}

QVOID cx_getUTCTime(QTime* p)
{
    if (p) {
    	cx_getLocalTime(p);
//        SYSTEMTIME t = {0};
//        GetSystemTime(&t);
//        p->wYear = (QUSHORT) t.wYear;
//        p->nMonth = (QBYTE) t.wMonth;
//        p->nDay = (QBYTE) t.wDay;
//        p->nHour = (QBYTE) t.wHour;
//        p->nMin = (QBYTE) t.wMinute;
//        p->nSec = (QBYTE) t.wSecond;
    }
}

QVOID cx_getTimeFromPlatformInt(QTime* p,QVOID* pInt)
{
	TInt64 *pTime = (TInt64*)pInt;
	TTime time(*pTime);
	
	TDateTime Date = time.DateTime();//.Day()
	p->wYear = Date.Year();
	p->nMonth =Date.Month();
	p->nDay = Date.Day();
	p->nHour = Date.Hour();
	p->nMin = Date.Minute();
	p->nSec =Date.Second();    		
	p->nMicroSec = Date.MicroSecond();
}


QVOID* cx_datetime_getData(QTime* p)
{
	TDateTime Date;// = time.DateTime();//.Day()
	Date.SetYear((int)p->wYear);
	TMonth month = (TMonth)p->nMonth;
	Date.SetMonth(month);
	Date.SetDay(p->nDay);
	Date.SetHour(p->nHour);
	Date.SetMinute(p->nMin);
	Date.SetSecond(p->nSec);
	Date.SetMicroSecond(p->nMicroSec);
	
	TTime time(Date); 
	TInt64 pTime = time.Int64();
	return (QVOID*)(&pTime);   		
}

#endif //CX_PLATFORM_WIN32
